Tree Column
This tutorial will explain workflow for working with Tree Column and tree structure of the grid.
Adding new column
Tree column can be added by opening Columns Editor and then clicking on TNxTreeColumn6 button (located under Additional tab).
Adding rows
Root (top-level) rows are added as normal rows by calling AddRow method.
NextGrid6.AddRow(3); // If more than one top-level rows is needed
Child rows are added by calling AddChildRow method. There are two overloaded versions of this method:
NextGrid61.AddChildRow(NextGrid61.Row[5], 3); // Reference to parent row as parameter NextGrid61.AddChildRow(NextGrid61.Row[NextGrid61.SelectedRow], 1)
First line adds 3 child rows inside row with absolute index 5. The second line add 1 row inside currently selected row.
Instance of
INxRow also includes several handy methods for working with child rows:
NextGrid61.Row[NextGrid61.SelectedRow].AddChildRow; NextGrid61.Row[NextGrid61.SelectedRow].AddChildRow(3); // Adds 3 rows at once
Position of the newly added row can be further specified by using the same method and specifying Position parameter:
uses NxCells6; NextGrid61.Row[NextGrid61.SelectedRow].AddChildRow(1, true, raLast);
New child row can be added as a sibling to another row:
NextGrid61.Row[2].AddSiblingRow;
Accessing and changing children
After child rows are added, they can either be accessed with using an absolute index (Row property of the grid) or via ChildRow array property of an existing row:
NextGrid61.Row[3].ChildRow[2].ChildRow[5].Height := 26;
Instance of INxRow also includes handful of useful properties such as: ChildRowCount, ChildShowingCount, FirstChild, LastChild.
Row can show or hide its children via Expanded property:
NextGrid61.Row[NextGrid61.SelectedRow].Expanded := False;